//
//  SPNavigationController.m
//  Sport
//
//  Created by Cass on 2017/11/15.
//  Copyright © 2017年 Cass. All rights reserved.
//

#import "SPNavigationController.h"

@interface SPNavigationController ()

@end

@implementation SPNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
//    self.navigationBar.translucent = NO;
//    [[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
    [self setupBasic];

}

- (void)setupBasic{
    [self.navigationBar setBackgroundImage:[UIImage getGradientImageWithSize:CGSizeMake(SCREEN_WIDTH, 64) locations:nil components:nil count:2] forBarMetrics:UIBarMetricsDefault];
    self.navigationBar.translucent = NO;
    self.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]};
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 50, 50)];
        [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        [button setImage:[UIImage imageNamed:@"btn_fanhui_1"] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside];
        viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:button];
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)popViewController{
    [self popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
